
# ifndef __DFX_IMAGE_H__
# define __DFX_IMAGE_H__

# include "dfxStream.h"
# include "dfxColor4.h"

namespace DFX
{
    enum IMAGE_FORMAT
    {
        IMAGE_FORMAT_BGR8,
        IMAGE_FORMAT_BGRA8,
        IMAGE_FORMAT_MAX
    };

    class DFX_EXPORT Image
    {
    protected:

        String          mName;
        IMAGE_FORMAT    mFormat;
        UInt32          mWidth;
        UInt32          mHeight;
        UInt32          mBitsPerPixel;
        UInt8           *mData;
        UInt32          mDataSize;

    public:

        Image(const String &name)
            : mName(name),
            mFormat(IMAGE_FORMAT_BGR8),
            mWidth(0),
            mHeight(0),
            mBitsPerPixel(24),
            mDataSize(0),
            mData(NULL)
        {
        }

        virtual ~Image()
        {
            Destroy();
        }

        IMAGE_FORMAT GetFormat() const
        {
            return mFormat;
        }

        UInt32 GetWidth() const
        {
            return mWidth;
        }

        UInt32 GetHeight() const
        {
            return mHeight;
        }

        UInt32 GetBitsPerPixel() const
        {
            return mBitsPerPixel;
        }

        UInt32 GetDataSize() const
        {
            return mDataSize;
        }

        UInt8* GetData() const
        {
            return mData;
        }

        virtual void ConvertToBGR();
        virtual void SetPixel(UInt32 x, UInt32 y, const Color4 &c);

        virtual void Clear();
        virtual void Rescale(UInt32 width, UInt32 height);

        virtual DFXRESULT Load(InputStream *stream, bool flipV);
        virtual DFXRESULT Destroy();
    };

    typedef std::vector<Image*> ImageArray;
}

# endif